package com.zzq.goods.rpc.provider;

import com.zzq.common.rpc.GoodsRpcService;
import com.zzq.goods.domain.MyGoods;
import com.zzq.goods.service.impl.GoodsServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;

@DubboService(version = "1.0.0", delay = -1, retries = 0)
@RequiredArgsConstructor
public class GoodsRpcServiceImpl implements GoodsRpcService {

    private final GoodsServiceImpl goodsService;

    @Override
    public Boolean reduceStock(String goodsId, Long count) {
        MyGoods myGoods = goodsService.getById(goodsId);
        myGoods.setGoodsStock(myGoods.getGoodsStock()-count);
        return goodsService.saveOrUpdate(myGoods);
    }




}
